package anatex.kea.genex;


import java.util.*;

import anatex.kea.*;
import anatex.domain.CustomLocale;
import anatex.domain.Document;
import anatex.domain.TrainingDocument;
import anatex.domain.KeywordExtractionModel;


public class GenEx extends AbstractAlgo {
	
	private Locale locale = new Locale("en", "US");
	
	private Document document;
	
	private List<TrainingDocument> trainingDocuments;
	
	public GenEx(Document doc){
		document = doc;
		CustomLocale l = doc.getCustomLocale();
		trainingDocuments = null;
		
		locale = new Locale(l.getShort_language(), l.getShort_country());
	}
	public GenEx(){
		document = null;
		trainingDocuments = null;
	}

	@Override
	public void extract(Document document, KeywordExtractionModel model) throws KeywordExtractorAlgoException {
		this.document = document;
		
		Genitor g = new Genitor();
		g.setModel(model);
		g.extractAndSaveKeywordsForDocument(document);
	}
	
	@Override
	public void setDocument (Document doc) {
		document = doc;
	}
	
	@Override
	public void setTrainingDocuments (List<TrainingDocument> trainingDocuments) {
		this.trainingDocuments = trainingDocuments;
	}
	
	@Override
	public void train (List<TrainingDocument> trainingDocuments) throws KeywordExtractorAlgoException {
		setTrainingDocuments(trainingDocuments);
		
		Genitor g = new Genitor();
		g.setTrainingDocuments(trainingDocuments);
		g.doTheEvolution();
	}

}
